<?php
class ControllerModuleAccount extends Controller {
	public function index() {
		$this->load->language('module/account');
		$this->load->language('english');
		
		$this->load->model('account/account_right');

		$data['heading_title'] = $this->language->get('heading_title');
		if (isset($this->session->data['token'])) {
			$token=$this->session->data['token'];
		} else {
			$token='';
		}
		$data['items'] = array();
		$logged = $this->customer->isLogged();
		if($logged){
			$results = $this->model_account_account_right->getItems('logged');
		}else{
			$results = $this->model_account_account_right->getItems('nologged');
		}
		foreach ($results as $result) {
			//自动把用户信息注册到闲置分组的表里
			if($result['name']=='idle'){
				$data['items'][] = array(
						'item_id' => $result['item_id'],
						'name'   => $this->language->get('text_'.$result['name']),
						'link' =>$this->url->idle_link('common/vdi_dashboard', '', 'SSL',$token),
						'logged' => $result['logged'],
						'nologged' => $result['nologged']
				);
			}else{
			$data['items'][] = array(
					'item_id' => $result['item_id'],
					'name'   => $this->language->get('text_'.$result['name']),
					'link' =>$this->url->link('account/'.$result['name'], '', 'SSL'),
					'logged' => $result['logged'],
					'nologged' => $result['nologged']
			);
		 }
		}
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/account.tpl')) {
			return $this->load->view($this->config->get('config_template') . '/template/module/account.tpl', $data);
		} else {
			return $this->load->view('default/template/module/account.tpl', $data);
		}
	}
}